Whittle away at more implicit time_t conversions. In some cases, I'm just
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 25 Jul 2013 20:43:47 +0000 (20:43 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 25 Jul 2013 20:43:47 +0000 (20:43 +0000)
moving the problem around, but these are all relatively obscure formats
anyway and pre-1970 times aren't that important for them anyway.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4476 f51c46e8-681c-474f-0cfe-069cfd0219fb

14 files changed:
gpsbabel/arcdist.cc
gpsbabel/compegps.cc
gpsbabel/destinator.cc
gpsbabel/exif.cc
gpsbabel/geoniche.cc
gpsbabel/gpssim.cc
gpsbabel/humminbird.cc
gpsbabel/igo8.cc
gpsbabel/jtr.cc
gpsbabel/navilink.cc
gpsbabel/pathaway.cc
gpsbabel/route.cc
gpsbabel/src/core/datetime.h
gpsbabel/xol.cc

index 60239360e177dfe67a0210ed51e04e469c8e2268..945f29f5b6e0c5b5f170afe166a5e242c50818a1 100644 (file)
@@ -230,8 +230,8 @@ arcdist_process(void)
           }
         }
         if (trkopt &&
-             (ed->arcpt2->creation_time != 0) &&
-             (ptsopt || (ed->arcpt1->creation_time != 0))) {
+             (ed->arcpt2->GetCreationTime().isValid()) &&
+             (ptsopt || (ed->arcpt1->GetCreationTime().isValid()))) {
           /* Interpolate time */
           if (ptsopt) {
             wp->creation_time = ed->arcpt2->creation_time;
index 9a8251b0b153304521ac3dace1a020ef1e470c62..a0e46f2d876c4b3247feb2c912bfdff9f9c0ed67 100644 (file)
@@ -561,7 +561,9 @@ write_trkpt_cb(const waypoint* wpt)
 
   buff[0] = '\0';
 
-  if (wpt->creation_time != 0) {
+// TOOD: This should probably attempt a gmtime and then fall back to the 1-1-1970
+// case or bypass the time_t completely and build string representations directly.
+  if (wpt->creation_time.isValid()) {
     const time_t tt = wpt->GetCreationTime();
     struct tm tm = *gmtime(&tt);
 
index e7c77d2f04386757446ca4893c4f036e83f3b085..3543fe3a3924ffc3d6ca8f7fbb764006c42910d6 100644 (file)
@@ -433,11 +433,11 @@ destinator_trkpt_disp(const waypoint* wpt)
     gbfputint32(0, fout);
   }
 
-  if (wpt->creation_time) {
+  if (wpt->creation_time.isValid()) {
     struct tm tm;
     double milliseconds;
     int date;
-    const time_t ct = wpt->GetCreationTime();
+    const time_t ct = wpt->GetCreationTime().toTime_t();
     tm = *gmtime(&ct);
     tm.tm_mon += 1;
     tm.tm_year -= 100;
index 73450a9d098737cd17c8dc6a3c94cd51a0f5dcb2..377b7144ba3d7267330f33662dd8e6755857b385 100644 (file)
@@ -1106,7 +1106,7 @@ exif_remove_tag(const int ifd_nr, const int tag_id)
 static void
 exif_find_wpt_by_time(const waypoint* wpt)
 {
-  if (wpt->creation_time <= 0) {
+  if (!wpt->creation_time.isValid()) {
     return;
   }
 
index 35a90eb3c66e18d991cebc843c871c595430309e..2c9f4610bd12d2cfe3f17049a7937fcda4cc328b 100644 (file)
@@ -746,7 +746,11 @@ geoniche_writewpt(const waypoint* wpt)
     id = rec_ct;
   }
 
-  tx = (wpt->GetCreationTime() != 0) ? wpt->GetCreationTime() : gpsbabel_time;
+  if (wpt->GetCreationTime().isValid()) {
+    tx = wpt->GetCreationTime().toTime_t();
+  } else {
+    tx = gpsbabel_time;
+  }
   if (tx == 0) {       /* maybe zero during testo (freezed time) */
     strcpy(datestr, "01/01/1904");     /* this seems to be the uninitialized date value for geoniche */
     strcpy(timestr, "00:00:00");
index abf9728e744b337fd68c6fef4fab931d19f2cac4..87976811cf2585a1ffe47bd71feb6c23dc672579 100644 (file)
@@ -121,12 +121,12 @@ gpssim_write_pt(const waypoint* wpt)
            wpt->altitude == unknown_alt ? 0 : wpt->altitude
           );
 
-  if (wpt->creation_time) {
+  if (wpt->creation_time.isValid()) {
     char tbuf[20];
     int hms, ymd;
     struct tm* tm;
 
-    const time_t tt = wpt->GetCreationTime();
+    const time_t tt = wpt->GetCreationTime().toTime_t();
     tm = gmtime(&tt);
     hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec;
     ymd = tm->tm_mday * 10000 + tm->tm_mon * 100 + tm->tm_year;
index 88bc0ae34eb8157d77a25310b6b213bf48b393b1..bc6fa67fef797b9f1271024a616be0d8247acaa3 100644 (file)
@@ -781,7 +781,7 @@ humminbird_track_cb(const waypoint* wpt)
   lat = geodetic_to_geocentric_hwr(wpt->latitude);
   north = si_round(inverse_gudermannian_i1924(lat));
 
-  if (wpt->creation_time != 0) {
+  if (wpt->creation_time.isValid()) {
     last_time = wpt->GetCreationTime();
   }
 
index 726830bdca1cea17a447e086edc00a8ddb4f5fa8..6c77e37d4db4f4dd3009f774112ff0591e64fe9e 100644 (file)
@@ -216,10 +216,10 @@ static void write_igo8_track_point(const waypoint* wpt)
   // iGo8 appears to expect a time, if one isn't provided
   // then we shall make our own, where each point is one
   // second apart.
-  if (wpt->creation_time == 0) {
-    le_write32(&point.unix_time, invented_time++);
-  } else {
+  if (wpt->creation_time.isValid()) {
     le_write32(&point.unix_time, wpt->GetCreationTime());
+  } else {
+    le_write32(&point.unix_time, invented_time++);
   }
 
   // Write the first part of the Information Block, the start time
index b4ec4d8d83b7d20eefb6445793d1517319fde715..adfc12b62c0791a206a2ad5c1b9e198845b798b9 100644 (file)
@@ -273,7 +273,7 @@ jtr_trkpt_disp_cb(const waypoint* wpt)
   char stime[10], sdate[7], scourse[6], sspeed[8];
   struct tm tm;
 
-  if (wpt->creation_time > 0) {
+  if (wpt->creation_time.isValid()) {
     const time_t tt = wpt->GetCreationTime();
     tm = *gmtime(&tt);
 
index 12c6a9557e3057db92cc77432671240d847b7ca1..dcbed7e8d35dc6e2b534eaebe9dfcdfbda63ae9a 100644 (file)
@@ -430,7 +430,7 @@ encode_waypoint(const waypoint* waypt, unsigned char* buffer)
   buffer[10] = 0;
   buffer[11] = 0;
   encode_position(waypt, buffer + 12);
-  encode_datetime(waypt->GetCreationTime(), buffer + 22);
+  encode_datetime(waypt->GetCreationTime().toTime_t(), buffer + 22);
   buffer[28] = find_icon_from_descr(waypt->icon_descr);
   buffer[29] = 0;
   buffer[30] = 0x00;
@@ -465,7 +465,7 @@ encode_trackpoint(const waypoint* waypt, unsigned serial, unsigned char* buffer)
   le_write32(buffer + 4, x);
   le_write32(buffer + 8, y);
   encode_position(waypt, buffer + 12);
-  encode_datetime(waypt->GetCreationTime(), buffer + 22);
+  encode_datetime(waypt->GetCreationTime().toTime_t(), buffer + 22);
   buffer[28] = z;
   buffer[29] = MPS_TO_KPH(WAYPT_GET(waypt, speed, 0) / 2);
   buffer[30] = 0x5a;
index 432d645c6162123402e44f7c61bd50dcaa57c38e..16a08ecac54c53c9d1d2902cb5766422fccf0add 100644 (file)
@@ -689,9 +689,9 @@ static void ppdb_write_wpt(const waypoint *wpt)
   buff = ppdb_strcat(buff, ",", NULL, &len);
   /* 4 time, date */
 
-  if (wpt->creation_time != 0) {
+  if (wpt->creation_time.isValid()) {
     tmp = str_pool_get(20);
-    const time_t tt = wpt->GetCreationTime();
+    const time_t tt = wpt->GetCreationTime().toTime_t();
     tm = *gmtime(&tt);
     strftime(tmp, 20, datefmt, &tm);
     buff = ppdb_strcat(buff, tmp, NULL, &len);
index a0c106bd897f6fafa9caabc8de5d511b2402f3e7..1e5b7e7bfbe3e5674efec8dbbe9fba647adfff3d 100644 (file)
@@ -570,9 +570,9 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
     *trkdatap = tdata;
   }
 
-  first.latitude = 0;
-  first.longitude = 0;
-  first.creation_time = 0;
+//  first.latitude = 0;
+//  first.longitude = 0;
+//  first.creation_time = 0;
   tdata->min_hrt =  9999;
   tdata->min_alt = -unknown_alt;
   tdata->max_alt =  unknown_alt;
index b6ca697b67a24984e894abc86ad6df685bc367f0..2e0f97f4e1215bb155824fa1bd33ea4759602417 100644 (file)
@@ -54,16 +54,6 @@ public:
     return t;
   }
 
-  time_t operator--(int) {
-    setTime_t(toTime_t() - 1);
-    return toTime_t();
-  }
-
-  time_t operator++(int) {
-    setTime_t(toTime_t() + 1);
-    return toTime_t();
-  }
-
   time_t operator+=(const time_t& t) {
     setTime_t(toTime_t() + t);
     return toTime_t();
index e6827716b85f75a19c285723d64a3d4e97547e4b..ff8418b3b5fc34195b02f9fe27122a8f5a21b9ce 100644 (file)
@@ -267,7 +267,7 @@ xol_waypt_disp_cb(const waypoint *wpt)
   xol_write_string("name", name);
   xol_write_string("comment", wpt->notes);
   xol_write_string("icon", wpt->icon_descr.toUtf8().data());
-  if (wpt->creation_time) {
+  if (wpt->creation_time.isValid()) {
     xol_write_time(wpt);
   }
   if (wpt->altitude != unknown_alt) {
@@ -309,7 +309,7 @@ xol_trkpt_disp_cb(const waypoint *wpt)
   }
 
   gbfprintf(fout, "%*s<shape type=\"waypoint\"", space++*2, "");
-  if (wpt->creation_time) {
+  if (wpt->creation_time.isValid()) {
     xol_write_time(wpt);
   }
   if (wpt->altitude != unknown_alt) {